package com.wondersgroup.app.util;

import java.lang.reflect.Method;
import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractPointcutAdvisor;
import org.springframework.aop.support.StaticMethodMatcherPointcut;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 访问日志相关AOP Advisor
 *
 * @author wanglei
 */
public class VisitAdvisor extends AbstractPointcutAdvisor {

    private final StaticMethodMatcherPointcut pointcut = new StaticMethodMatcherPointcut() {
        @Override
        public boolean matches(Method method, Class<?> targetClass) {
            return (method.isAnnotationPresent(RequestMapping.class));
        }
    };

    private VisitMethodAdvice visitMethodAdvice;
    
    @Override
    public Pointcut getPointcut() {
        return this.pointcut;
    }

    @Override
    public Advice getAdvice() {
        return this.visitMethodAdvice;
    }

    public VisitMethodAdvice getVisitMethodAdvice() {
        return visitMethodAdvice;
    }

    public void setVisitMethodAdvice(VisitMethodAdvice visitMethodAdvice) {
        this.visitMethodAdvice = visitMethodAdvice;
    }

}
